/*
 * @Author: shengduiliang 1107722390@qq.com
 * @Date: 2024-05-04 18:29:39
 * @LastEditors: shengduiliang 1107722390@qq.com
 * @LastEditTime: 2024-05-04 21:47:52
 * @FilePath: /treasure/src/ui-components/date-picker/index.tsx
 * @Description: 日期选择器
 */
import { Picker, View } from "@tarojs/components"
import classNames from "classnames"
import './index.scss'

interface TimePickerProps {
  label: string
  placeholder: string
  value?: string
  onChange: (value: string) => void
}


const DatePicker = ({ label, placeholder, value, onChange }: TimePickerProps) => {
  return (
    <View className='date-picker pv-normal-mh-normal row-between-center'>
      <View className='label text-primary-bold'>{label}</View>
      <View className='flex-1'>
        <Picker mode='time' onChange={(e) => onChange(e.detail.value)} value={value || ''}>
          <View
            className={classNames({
              'text-secondary': !value,
              'text-primary': value,
            })}
          >
            {value || placeholder}
          </View>
        </Picker>
      </View>
    </View>
  )
}

export default DatePicker;